<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 100px;
            height: 100px;
            background: red;
            position: absolute;
            left: 0;
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
<script>
    /*
        动画中必须使用定时器
        匀速运动：在相同的事件内容运动的距离一样
    */
   var box = document.querySelector('.box');
   //  鼠标滑过，box的让元素移动到1000的位置
   var left = 0;
   box.onmouseover = function(){
       let timer = setInterval(() => {
            //每执行一次就加13
            left += 13;
            // 结束条件
            if(left >= 1000){
                left = 1000;
                clearInterval(timer);
            }
            box.style.left = left + 'px';
       },10)
   }
</script>
</html>